﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
public partial class 系统管理_add_xgxz : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (null == Request.QueryString["code"])
            {
                Response.Redirect("list_zjzh.aspx"); 
            }
            else
            {
                this.code.Text = Request.QueryString["code"];
                this.LinkButton1.PostBackUrl = "list_xgxz.aspx?code=" + Request.QueryString["code"];

            }
        }
    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.type.SelectedValue.ToString() == "2")
        {
            this.BiLi.Text = "0";
            this.RegularExpressionValidator1.Enabled = false;
            this.BiLi.ReadOnly = true;
        }
        else
        {
            this.RegularExpressionValidator1.Enabled = true;
            this.BiLi.ReadOnly = false;
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        StringBuilder strSql2 = new StringBuilder();
        strSql2.Append("insert into 险种表(");
        strSql2.Append("code,name,type,BiLi,info)");
        strSql2.Append(" values (");
        strSql2.Append("@code,@name,@type,@BiLi,@info)");
        SqlParameter[] parameters2 = {
						new SqlParameter("@code", SqlDbType.NVarChar,50),
						new SqlParameter("@name", SqlDbType.NVarChar,50),
						new SqlParameter("@type", SqlDbType.Int,4),
						new SqlParameter("@BiLi", SqlDbType.Float,8),
						new SqlParameter("@info", SqlDbType.NVarChar,255)};
        parameters2[0].Value = this.code.Text;
        parameters2[1].Value = this.name.Text;
        parameters2[2].Value = Convert.ToInt32( this.type.Text);
        parameters2[3].Value = Convert.ToDecimal( this.BiLi.Text);
        parameters2[4].Value = this.info.Text;
        DataBase.runExecute(strSql2.ToString(), parameters2);
        Response.Redirect("list_xgxz.aspx?code="+this.code.Text);
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedValue != "1")
        {
            this.name.Text = this.DropDownList1.SelectedValue;
        }
        else
        {
            this.name.Text = "";
        }
    }
}
